#ifndef _BSP_PORT_H_
#define _BSP_PORT_H_

#include "main.h"
#include "stdio.h"
#include "string.h"
#include "stdbool.h"

/************************** GPIO *********************************/
#define LED_RUN_OPEN LL_GPIO_SetOutputPin(LED_RUN_GPIO_Port, LED_RUN_Pin)   // 打开运行指示灯
#define LED_RUN_SHUT LL_GPIO_ResetOutputPin(LED_RUN_GPIO_Port, LED_RUN_Pin) // 关闭运行指示灯
#define LED_RUN_TOGG LL_GPIO_TogglePin(LED_RUN_GPIO_Port, LED_RUN_Pin)      // 翻转运行指示灯
#define LED_RUN_ISIN LL_GPIO_IsInputPinSet(LED_RUN_GPIO_Port, LED_RUN_Pin)  // 读取运行指示灯

#define WATER_PLACE_01_ISIN LL_GPIO_IsInputPinSet(TESTIO_01_GPIO_Port, TESTIO_01_Pin) // 读取拨码开关1
#define WATER_PLACE_02_ISIN LL_GPIO_IsInputPinSet(TESTIO_02_GPIO_Port, TESTIO_02_Pin) // 读取拨码开关1

/************************** xxxx *********************************/
#define RST_2G4_OPEN LL_GPIO_SetOutputPin(RST_2G4_GPIO_Port, RST_2G4_Pin)   // 打开
#define RST_2G4_SHUT LL_GPIO_ResetOutputPin(RST_2G4_GPIO_Port, RST_2G4_Pin) // 关闭

typedef enum
{
    BSP_UART1,
    BSP_UART2,
} Bsp_Uart_t;

#define bsp_mDelay(ms) LL_mDelay(ms)

extern volatile uint64_t TimestampCnt; // 用来定时
void bsp_Delay_us(uint32_t us);
void bsp_uart_SendData(Bsp_Uart_t Uart, uint8_t *data, uint16_t datalen);
uint64_t get_Timestampus(void);
void TimestampInc(uint32_t Time);

int fputc(int ch, FILE *stream);
void bsp_USART_SendBytes(uint8_t *Buf, uint8_t length);
void bsp_IWDG_ReloadCounter(void);

#endif

// Kettle 水壶
// Water 水
